﻿using System;
using System.Linq;
using System.Collections.Generic; 
using System.Data;
using Matrix.Common.Utility;
using Matrix.MaKaYunShang.DAL;
using Matrix.MaKaYunShang.Model;

namespace Matrix.MaKaYunShang.BLL
{
	public partial class SysMessageBLL : BaseBLL<SysMessageBLL>
	{
		#region 默认方法
		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(SysMessage model)
		{
			return SysMessageDAL.Instance.Add(model);		
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(SysMessage model)
		{
			return SysMessageDAL.Instance.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int Id)
		{			
			return SysMessageDAL.Instance.Delete(Id);
		}
				/// <summary>
		/// 批量删除一批数据
		/// </summary>
		public bool DeleteList(string Idlist )
		{
			return SysMessageDAL.Instance.DeleteList(Idlist );
		}
		
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public SysMessage GetModel(int Id)
		{
			var ds = SysMessageDAL.Instance.GetModel(Id);
            return ds == null ? null : ServicesHelper.DataSetToIList<SysMessage>(ds).ToList()[0];
		}
		
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<SysMessage> GetModelList(string strWhere = null)
		{
			var ds = SysMessageDAL.Instance.GetList(strWhere);
			return ServicesHelper.DataSetToIList<SysMessage>(ds).ToList();
		}
		#endregion
		
		#region 扩展方法
        /// <summary>
        /// 查询用户系统消息
        /// </summary>
        /// <remarks>crate lk 2016-06-12</remarks>
        /// <returns></returns>
        public JsonModel.PageList<SysMessage> GetSysMessageList(int pageIndex, int pageSize, int userId)
        {
            try
            {
                var totalCount = 0;
                var list = SysMessageDAL.Instance.GetSysMessageList(pageIndex, pageSize, userId, ref totalCount);
                return new JsonModel.PageList<SysMessage>(list, totalCount);
            }
            catch (Exception ex)
            {
                _fileLog.Error(" GetList | Exception: " + ex);
                return null;
            }
        }
		#endregion
	}
}